package Io;

import java.io.*;

public class BufferedWriter_1 {
    public static void main(String[] args) {
        BufferedWriter bw = null;
        BufferedReader ipsr=null;

        try {
            FileOutputStream fos = new FileOutputStream("node.TXT",true);  //定义一个字节流
            OutputStreamWriter opsw = new OutputStreamWriter(fos);             //转换流，将字节流转换为字符流
            bw = new BufferedWriter(opsw);                                     //将转换的字符流传入缓冲流
            bw.write("今天也要加油哦！");

            FileReader fr=new FileReader("node.TXT");                  //定义一个字符流
            ipsr=new BufferedReader(fr);                                        //将字符流传入缓冲流

            String line=null;
            while ((line=ipsr.readLine())!=null){
                System.out.println(line);
            }

            bw.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                ipsr.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }
}
